#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;

void Test1()
{
	string str;
	queue < char> q;

}

int main1()
{
    string str, str1;
    cin >> str;
    queue<char> q;
    str += 'c';
    for (int i = 0; i < str.size(); i++)
    {
        if (str[i] >= '0' && str[i] <= '9')
        {
            q.push(str[i]);
        }
        else
        {
            if (!q.empty())
            {
                if (q.size() > str1.size())
                {
                    str1.clear();
                    while (!q.empty())
                    {
                        str1 += q.front();
                        q.pop();
                    }
                }
                else
                {
                    while (!q.empty())
                    {
                        q.pop();
                    }
                }
            }
        }
    }

    cout << str1;
    return 0;
}

void Test2()
{

    int m, n;
    cin >> m >> n;
    vector<vector<int>> arr;
    vector<int> tmp;
    char ch;
    for (int i = 0; i < m; i++)
    {
        tmp.clear();
        for (int j = 0; j < n; j++)
        {
            cin >> ch;
            if (ch == 'l')
                tmp.push_back(4);

            else if (ch == 'o')
                tmp.push_back(3);

            else if (ch == 'v')
                tmp.push_back(2);

            else if (ch == 'e')
                tmp.push_back(1);

            else
                tmp.push_back(0);
        }
        arr.push_back(tmp);
    }
    for (int i = 1; i < m; i++)
    {
        arr[i][0] += arr[i - 1][0];
    }
    for (int i = 0; i < n; i++)
    {
        arr[0][i] += arr[0][i - 1];
    }

    for (int i = 1; i < m; i++)
    {
        for (int j = 1; j < n; j++)
        {
            arr[i][j] += max(arr[i - 1][j], arr[i][j - 1]);
        }
    }
    cout << arr[m - 1][n - 1];
}


void Test3()
{
    vector<vector<int>> arr;
    vector<int> tmp;
    int x = 0;
    for (int i = 0; i < 3; i++)
    {
        tmp.clear();
        for (int j = 0; j < 2; j++)
        {
            cin >> x;
            tmp.push_back(x);
        }
        for (auto e : tmp)
        {
            cout << e << " ";
        }
        cout << endl;

        arr.push_back(tmp);
    }

}


int main()
{

    Test2();

    return 0;
}